#include "init_message.h"

init_message::init_message(QWidget *parent) : QMainWindow(parent)
{
    this->setStyleSheet("QMainWindow{background-image: url(:/pic/启动页.jpg);}");
    this->setFixedSize(640,430);

timer = new QTimer(this);
timer->start(750);
timer2 = new QTimer(this);
timer2->setInterval(400);
timer3 = new QTimer(this);
timer3->setInterval(400);
timer4 = new QTimer(this);
timer4->setInterval(400);
ui_init();
connect_init();
}
void init_message::connect_init()
{

    //刷新
    connect(timer,&QTimer::timeout,[=](){
        cnt++;
        switch (cnt) {
        case 1:
        {
            theLabel[0]->show();
            break;
        }
        case 2:
        {
            theLabel[1]->show();
            timer2->start();
            break;
        }
        case 3:
        {
            theLabel[2]->show();
            break;
        }
        case 4:
        {
            theLabel[3]->show();
            timer3->start();
            break;
        }
        case 5:
        {
            theLabel[4]->show();
            timer4->start();
            break;
        }
        default:
            break;
        }
        if(cnt==6)
        {
            init_Show *init = new init_Show(this);
            init->show();
            this->hide();
        }
    });
    //内存
    connect(timer2,&QTimer::timeout,[=](){
        theLabel[5]->setText(tr("OK"));
    });
    //接口板
    connect(timer3,&QTimer::timeout,[=](){
        if(Sysstatus->BD_Int_IsPresent)
            theLabel[6]->setText(tr("OK"));
        else
            theLabel[6]->setText(tr("Fail"));
    });
    //臭氧板
    connect(timer4,&QTimer::timeout,[=](){
        if(Sysstatus->BD_Ozo_IsPresent)
            theLabel[7]->setText(tr("OK"));
        else
            theLabel[7]->setText(tr("Fail"));
    });
}

void init_message::ui_init()
{
    for(int i=0;i<8;i++)//创建界面显示的label
    {
         theLabel[i] = new QLabel(this);
         theLabel[i]->setStyleSheet("QLabel{\
                                outline: 0px ;                            /* 去掉获取焦点时的虚线 */ \
                                border-radius: 6px;		                 /* 按钮边框的圆角设置 */\
                                border-style: outset;\
                                /* 按钮文本设置 */\
                                font-size: 20px;\
                                color: #FFFFFF;			                 /* 文本颜色 */\
                           }"
          );
    }

    theLabel[0]->setText("Initializing  Memory                          . . . . . . . . . . . . . . . . . . . . . . . . . . ");
    theLabel[1]->setText("Memory                     :       ");
    theLabel[2]->setText("Initializing  Hardware. . . . . . . . . . . . . ");
    theLabel[3]->setText("Interfaceboard       :      ");
    theLabel[4]->setText("O3 board          :      ");
    theLabel[0]->setGeometry(20,200,50,35);
    theLabel[1]->setGeometry(20,240,250,35);
    theLabel[2]->setGeometry(20,280,300,35);
    theLabel[3]->setGeometry(20,320,220,35);
    theLabel[4]->setGeometry(20,360,220,35);

    theLabel[5]->setGeometry(270,240,220,35);
    theLabel[6]->setGeometry(270,320,220,35);
    theLabel[7]->setGeometry(270,360,220,35);


   }




